package com.eqdd.yiqidian.ui.mine.daka;

import android.databinding.DataBindingUtil;
import android.support.v7.widget.LinearLayoutManager;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.eqdd.yiqidian.MyDakaActivityCustom;
import com.eqdd.yiqidian.R;
import com.eqdd.yiqidian.adapter.slimadapter.SlimAdapterEx;
import com.eqdd.yiqidian.adapter.slimadapter.SlimInjector;
import com.eqdd.yiqidian.adapter.slimadapter.viewinjector.IViewInjector;
import com.eqdd.yiqidian.base.BaseActivity;
import com.eqdd.yiqidian.bean.SecondBean;

import java.util.ArrayList;

public class MyDakaActivity extends BaseActivity {
    private MyDakaActivityCustom dataBinding;
    private ArrayList<SecondBean> secondBeen;
    private SlimAdapterEx slimAdapterEx;

    @Override
    public void initBinding() {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_my_daka);
        initTopTitleBar(View.VISIBLE, "我的打卡");
        initTopRightText("2017/06",v->{

        });
    }

    @Override
    public void initData() {
        secondBeen = new ArrayList<>();
        secondBeen.add(new SecondBean("出勤","1天"));
        secondBeen.add(new SecondBean("出差打卡","1天"));
        secondBeen.add(new SecondBean("迟到","1次"));
        secondBeen.add(new SecondBean("早退","3次"));
        secondBeen.add(new SecondBean("漏打卡","1次"));
        secondBeen.add(new SecondBean("矿工","1次"));
    }

    @Override
    public void setView() {
        dataBinding.recyclerView.setLayoutManager(new LinearLayoutManager(this));
        slimAdapterEx = SlimAdapterEx.create().register(R.layout.list_item_08, new SlimInjector<SecondBean>() {
            @Override
            public void onInject(SecondBean data, IViewInjector injector) {

                injector.text(R.id.tv_upper_content,data.getFirst());
                injector.text(R.id.tv_down_content,data.getSecond());
                injector.with(R.id.tv_down_content, v->{
                    TextView view= (TextView) v;
                    view.setGravity(Gravity.CENTER_VERTICAL|Gravity.RIGHT);
                    view.setTextSize(180);
                });
            }
        }).attachTo(dataBinding.recyclerView);
        slimAdapterEx.updateData(secondBeen);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {

        }
    }
}
